{% extends 'base.html' %}

{% block title %}工作流模板管理{% endblock %}

{% block content %}
<div class="container-fluid">
    <div class="row">
        <div class="col-12">
            <div class="d-flex justify-content-between align-items-center mb-4">
                <h2><i class="fas fa-sitemap me-2"></i>工作流模板管理</h2>
                <a href="{% url 'assets:workflow_template_create' %}" class="btn btn-primary">
                    <i class="fas fa-plus me-1"></i>新建模板
                </a>
            </div>

            <div class="card">
                <div class="card-body p-0">
                    <div class="table-responsive">
                        <table class="table table-hover mb-0">
                            <thead class="table-light">
                                <tr>
                                    <th>模板名称</th>
                                    <th>类型</th>
                                    <th>版本</th>
                                    <th>状态</th>
                                    <th>创建人</th>
                                    <th>创建时间</th>
                                    <th>操作</th>
                                </tr>
                            </thead>
                            <tbody>
                                {% for tpl in templates %}
                                <tr>
                                    <td>{{ tpl.name }}</td>
                                    <td>{{ tpl.get_template_type_display }}</td>
                                    <td>{{ tpl.version }}</td>
                                    <td>
                                        {% if tpl.is_active %}
                                            <span class="badge bg-success">已启用</span>
                                        {% else %}
                                            <span class="badge bg-secondary">已禁用</span>
                                        {% endif %}
                                    </td>
                                    <td>{{ tpl.created_by.username|default:"-" }}</td>
                                    <td>{{ tpl.created_at|date:"Y-m-d H:i" }}</td>
                                    <td>
                                        <a href="{% url 'assets:workflow_template_edit' tpl.id %}" class="btn btn-sm btn-outline-primary">
                                            <i class="fas fa-edit"></i> 编辑
                                        </a>
                                        <a href="{% url 'assets:workflow_template_delete' tpl.id %}" class="btn btn-sm btn-outline-danger">
                                            <i class="fas fa-trash"></i> 删除
                                        </a>
                                    </td>
                                </tr>
                                {% empty %}
                                <tr>
                                    <td colspan="7" class="text-center py-5">
                                        <p class="text-muted">暂无工作流模板</p>
                                        <a href="{% url 'assets:workflow_template_create' %}" class="btn btn-primary">立即创建</a>
                                    </td>
                                </tr>
                                {% endfor %}
                            </tbody>
                        </table>
                    </div>
                </div>
            </div>
        </div>
    </div>
</div>
{% endblock %}
